home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / ab20_archive / datacomm / vltphone.lzh / addnum.rexx < prev    next >
OS/2 REXX Batch file  |  1990-08-07  |  10KB  |  318 lines

  1. /* Quickie macro to add names and numbers to the Autodialer */
  2. /* phonebook. Beta version .7, use with caution.               */
  3. /* This program is copyright 1990, Dan Sugalski. */
  4. /* The archive it appears in may be freely redistributed */
  5. /* provided that it remains intact */
  6.  
  7.  
  8. if ~show(l,"rexxsupport.library") then
  9.     call addlib("rexxsupport.library",0,-30,0)
  10. if ~show(l,"rexxarplib.library") then
  11.     call addlib("rexxarplib.library",0,-30,0)
  12.  
  13. called = address()
  14.  
  15. if called = VLT then do
  16.     screen = ',VLT'
  17.     screenx = screencols(VLT)
  18.     if screenx ~= -1 then do
  19.         screeny = screenrows(VLT)
  20.         end
  21.     else do
  22.         screen = ''
  23.         screenx = screencols()
  24.         screeny = screenrows()
  25.         end
  26.     end
  27. else do
  28.     screen = ''
  29.     screenx = screencols()
  30.     screeny = screenrows()
  31.     end
  32.  
  33.  
  34. if (called = "VLT") then do
  35.     address vlt
  36.     rx "{call createhost updater, updater2" screen "}"    /* Here we open through VLT, as it */
  37.     end                                                   /* called it. We use the VLT screen*/
  38.                                                           /* if it exists.                   */
  39. else do
  40.     address command
  41.     run rx '"call createhost updater, updater2"'
  42.     end
  43.  
  44. call openport(updater2)
  45.  
  46. do i=1 to 10 while ~showlist(P,UPDATER)
  47.     call delay 50
  48.     end
  49.  
  50. if ~showlist(p, UPDATER) then do
  51.     say "Can't open Host port!"
  52.     exit 1
  53.     end
  54.  
  55. if ~open(updatephone,'S:VLTPhone',r) then do
  56.     if ~open(updatephone, 'S:VLTPhone',w) then do
  57.         call postmsg(100,60,"Can't open phone file!")
  58.         call delay 200
  59.         call postmsg()
  60.         exit 1
  61.         end
  62.     else do
  63.         call close(updatephone)
  64.         call open(updatephone, 'S:vltphone',r)
  65.         end
  66.     end
  67.  
  68. do entr=1 while ~eof(updatephone)
  69.     line = readln(updatephone)
  70.     parse var line phone.name.entr phone.number.entr phone.macro.entr phone.parity.entr phone.strip.entr
  71.     end
  72.  
  73. call close(updatephone)
  74.  
  75. entr = entr - 1
  76.  
  77. do while (phone.name.entr = '')
  78.         entr = entr - 1
  79.         end
  80.  
  81. call postmsg(300, 75, "One Moment, setting up constants")
  82.  
  83. winx = screenx - 51
  84. winy = screeny - 40
  85.  
  86. tempx = winx-160+16+24-(13+26)
  87. parity.x1.8n1 = tempx
  88. parity.x1.8m1 = tempx
  89. parity.x1.8s1 = tempx
  90. parity.x1.8e1 = tempx
  91. parity.x1.8o1 = tempx
  92.  
  93. tempx = tempx + 34
  94. parity.x1.8n2 = tempx
  95. parity.x1.7m1 = tempx
  96. parity.x1.7s1 = tempx
  97. parity.x1.7e1 = tempx
  98. parity.x1.7o1 = tempx
  99.  
  100. tempx = tempx + 34
  101. parity.x1.7n2 = tempx
  102. parity.x1.7m2 = tempx
  103. parity.x1.7s2 = tempx
  104. parity.x1.7e2 = tempx
  105. parity.x1.7o2 = tempx
  106.  
  107. parity.y1.8n1 = 93
  108. parity.y1.8m1 = 106
  109. parity.y1.8s1 = 119
  110. parity.y1.8e1 = 132
  111. parity.y1.8o1 = 145
  112.  
  113. parity.y1.8n2 = 93
  114. parity.y1.7m1 = 106
  115. parity.y1.7s1 = 119
  116. parity.y1.7e1 = 132
  117. parity.y1.7o1 = 145
  118.  
  119. parity.y1.7n2 = 93
  120. parity.y1.7m2 = 106
  121. parity.y1.7s2 = 119
  122. parity.y1.7e2 = 132
  123. parity.y1.7o2 = 145
  124.  
  125. call postmsg()
  126.  
  127. call openwindow(UPDATER, 0, 0, winx, winy, "CLOSEWINDOW+GADGETUP", "WINDOWCLOSE+WINDOWDEPTH+WINDOWDRAG", "VLT autodialer phone entry editor")
  128.  
  129.  
  130. curentry = 1
  131. if curentry > entr then do
  132.     phone.name.curentry = ''
  133.     phone.number.curentry = ''
  134.     phone.macro.curentry = 'dummy'
  135.     phone.parity.curentry = '8N1'
  136.     phone.strip.curentry = 'No'
  137.     entr = 1
  138.     end
  139. gadgets = 0
  140.  
  141. /* trace r */
  142.  
  143. do dummy1 = 1
  144.     edit.name = phone.name.curentry
  145.     edit.number = phone.number.curentry
  146.     edit.macro = phone.macro.curentry
  147.     edit.parity = phone.parity.curentry
  148.     edit.strip = strip(phone.strip.curentry, 'L')
  149.     call dogadgets
  150.     do dummy2 = 1
  151.         do dummy3 = 1
  152.             token = getpkt(updater2)
  153.             if token = '0000 0000'x then leave
  154.             myarg = getarg(token)
  155.             call reply(token)
  156.             gadgetnum = left(myarg, 2)
  157.  
  158.             select
  159.  
  160.                 when myarg = "CLOSEWINDOW" then do
  161.                     leave dummy1
  162.                     end
  163.  
  164.                 when gadgetnum = 01 then do
  165.                     edit.name = right(myarg, length(myarg)-2)
  166.                     call activategadget(updater, 2)
  167.                     end
  168.  
  169.                 when gadgetnum = 02 then do
  170.                     edit.number = right(myarg, length(myarg)-2)
  171.                     call activategadget(updater, 3)
  172.                     end
  173.  
  174.                 when gadgetnum = 03 then do
  175.                     edit.macro = right(myarg, length(myarg)-2)
  176.                     call activategadget(updater, 1)
  177.                     end
  178.  
  179.                 when gadgetnum = 'ST' then do
  180.                     edit.strip = right(myarg, length(myarg)-2)
  181.                     call dogadgets
  182.                     end
  183.  
  184.                 when gadgetnum = 'PA' then do
  185.                     edit.parity = right(myarg, length(myarg)-2)
  186.                     call dogadgets
  187.                     end
  188.  
  189.                 when gadgetnum = 'NX' then do
  190.                     phone.name.curentry = space(strip(edit.name, 'B'),1,'_')
  191.                     phone.number.curentry = compress(edit.number)
  192.                     phone.macro.curentry = compress(edit.macro)
  193.                     phone.strip.curentry = edit.strip
  194.                     phone.parity.curentry = edit.parity
  195.                     curentry = curentry + 1
  196.                     if curentry > entr then curentry = entr
  197.                     leave dummy2
  198.                     end
  199.  
  200.                 when gadgetnum = 'PR' then do
  201.                     phone.name.curentry = space(strip(edit.name, 'B'),1,'_')
  202.                     phone.number.curentry = compress(edit.number)
  203.                     phone.macro.curentry = compress(edit.macro)
  204.                     phone.strip.curentry = edit.strip
  205.                     phone.parity.curentry = edit.parity
  206.                     curentry = curentry - 1
  207.                     if curentry < 1 then curentry = 1
  208.                     leave dummy2
  209.                     end
  210.  
  211.                 when gadgetnum = 'NE' then do
  212.                     entr = entr + 1
  213.                     curentry = entr
  214.                     phone.name.entr = ''
  215.                     phone.number.entr = ''
  216.                     phone.macro.entr = 'dummy'
  217.                     phone.strip.entr = 'No'
  218.                     phone.parity.entr = '8N1'
  219.                     leave dummy2
  220.                     end
  221.  
  222.                 when gadgetnum = 'SA' then do
  223.                     temp = 'dummy value'
  224.                     do while (~open(updatephone, 'S:VLTPhone', 'W') & (temp ~= ''))
  225.                        temp = request(250, 75, "Can't open S:VLTPhone!",,"Retry", "Cancel")
  226.                         end
  227.                     if temp ~= '' then do
  228.                         do temp = 1 to entr
  229.                             if phone.name.temp ~= '' then call writeln(updatephone, phone.name.temp phone.number.temp phone.macro.temp phone.parity.temp phone.strip.temp)
  230.                             end
  231.                         call close(updatephone)
  232.                         end
  233.                     else nop
  234.                     end
  235.  
  236.                 otherwise nop
  237.  
  238.                 end
  239.             end
  240.         call waitpkt(updater2)
  241.         end
  242.     end
  243.  
  244. call closewindow(updater)
  245. exit 0
  246.  
  247.  
  248.  
  249. dogadgets:
  250.  
  251.     if gadgets = 1 then
  252.         do d1 = 1 to 24
  253.             call removegadget(UPDATER, d1)
  254.             end
  255.  
  256.         gadgets = 1
  257.  
  258.     call setapen(updater,0)
  259.     call setdrmd(updater, jam1)
  260.     call rectfill(updater,2,12,winx-2, winy-2)
  261.     call setAPen(UPDATER, 1)
  262.     call move(UPDATER,(winx/2)-40, 20)
  263.     call text(UPDATER, "Board Name")
  264.     call move(UPDATER, 80, 50)
  265.     call text(UPDATER, "Phone Number")
  266.     call move(UPDATER, winx - 160 ,50)
  267.     call text(updater, "Macro Name")
  268.     call move(updater, 76, 80)
  269.     call text(updater, "Strip Bit 8?")
  270.     call move(updater, winx-160+16, 80)
  271.     call text(updater, "Parity")
  272.     call move(updater, winx/2 - (24+ 28), 75)
  273.     call text(updater, "Record Number")
  274.     call move(updater, winx/2 - 16, 85)
  275.     call text(updater, curentry)
  276.  
  277.     call addgadget(updater, (winx/2)-61, 30, 1, edit.name, "01%g", 120)
  278.     call addgadget(updater, 33, 60, 2, edit.number, "02%g", 200)
  279.     call addgadget(updater, winx-221, 60, 3, edit.macro, "03%g", 200)
  280.     call addgadget(updater, 76, 90, 4, "Yes", "STY")
  281.     call addgadget(updater, 154, 90, 5, "No", "STN")
  282.     call addgadget(updater, 20, winy-15, 6, "Next", "NX")
  283.     call addgadget(updater, 65, winy-15, 7, "Prev", "PR")
  284.     call addgadget(updater, 110, winy-15, 8, "New", "NE")
  285.     call addgadget(updater, 150, winy-15, 9, "Save", "SA")
  286.  
  287.     tempx = winx-160+16+24-(13+26)
  288.     call addgadget(updater,tempx, 93, 10, "8N1", "PA8N1")
  289.     call addgadget(updater,tempx, 106, 11, "8M1", "PA8M1")
  290.     call addgadget(updater,tempx, 119, 12, "8S1", "PA8S1")
  291.     call addgadget(updater,tempx, 132, 13, "8E1", "PA8E1")
  292.     call addgadget(updater,tempx, 145, 14, "8O1", "PA8O1")
  293.  
  294.     tempx = tempx + 34
  295.     call addgadget(updater,tempx, 93, 15, "8N2", "PA8N2")
  296.     call addgadget(updater,tempx, 106, 16, "7M1", "PA7M1")
  297.     call addgadget(updater,tempx, 119, 17, "7S1", "PA7S1")
  298.     call addgadget(updater,tempx, 132, 18, "7E1", "PA7E1")
  299.     call addgadget(updater,tempx, 145, 19, "7O1", "PA7O1")
  300.  
  301.     tempx = tempx + 34
  302.     call addgadget(updater,tempx, 93, 20, "7N2", "PA7N2")
  303.     call addgadget(updater,tempx, 106, 21, "7M2", "PA7M2")
  304.     call addgadget(updater,tempx, 119, 22, "7S2", "PA7S2")
  305.     call addgadget(updater,tempx, 132, 23, "7E2", "PA7E2")
  306.     call addgadget(updater,tempx, 145, 24, "7O2", "PA7O2")
  307.  
  308.     call SetDrMd(Updater, COMPLEMENT)
  309.     if ((left(edit.strip,1) = "y") | (left(edit.strip,1) = "Y")) then
  310.         call RectFill(updater, 76, 90, 76+26, 99)
  311.     else
  312.         call RectFill(updater, 154, 90, 154+18, 99)
  313.  
  314.     interm = edit.parity
  315.  
  316.     call RectFill(updater, parity.x1.interm, parity.y1.interm, parity.x1.interm + 26, parity.y1.interm + 9)
  317.     return 0
  318.